﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Subsidiary.BookSearch;
using System.Diagnostics;
using System.Configuration;

namespace Subsidiary
{
    public partial class BookForm : UserControl
    {
        public BookForm()
        {
            InitializeComponent();
        }

        private void btnGrab_Click(object sender, EventArgs e)
        {
            Search seach = new Search();
            BookItem book = seach.SearchBook(tbBookName.Text.Trim());
            if (book.Id == null)
            {
                MessageBox.Show("出错了");
                return;
            }
            SaveBook(book);

            Process.Start("Explorer", ConfigurationManager.AppSettings["PictureFolder"]);
            Process.Start("Explorer", ConfigurationManager.AppSettings["DataFolder"]);

            MessageBox.Show("抓取完成");
        }

        void SaveBook(BookItem book)
        {
            book.InsertBook(book);
        }
    }
}
